package com.sit.service.impl;

import com.sit.service.CaptchaService;
import com.sit.utils.CaptchaImgUtil;
import jakarta.servlet.http.HttpSession;
import org.springframework.stereotype.Service;
import java.io.IOException;

@Service
public class CaptchServiceImpl implements CaptchaService {
    @Override
    public void storeCaptchaInSession(HttpSession session, int length) {
        try {
            CaptchaImgUtil.storeCaptchaInSession(session, length);
        }
        catch (Exception e){
            throw new RuntimeException(e);
        }
    }

    @Override
    public byte[] generateCaptchaImage(int width, int height, int length) {
        try {
            return CaptchaImgUtil.generateCaptchaImage(width, height, length);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
